package com.xuanwei.core.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xuanwei.core.service.IXwOrderRefundRecordService;
import com.xuanwei.dao.entity.XwOrderRefundRecord;
import com.xuanwei.dao.mapper.XwOrderRefundRecordMapper;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author mjy
 * @since 2019-07-11
 */
@Service
public class XwOrderRefundRecordServiceImpl extends ServiceImpl<XwOrderRefundRecordMapper, XwOrderRefundRecord> implements IXwOrderRefundRecordService {

    @Override
    public void save(Integer refundId, String message) {
        XwOrderRefundRecord orderRefundRecord = new XwOrderRefundRecord();
        orderRefundRecord.setCreateTime(LocalDateTime.now());
        orderRefundRecord.setOrderRefundId(refundId);
        orderRefundRecord.setMessage(message);
        save(orderRefundRecord);
    }

    @Override
    public void save(Integer refundId, String message, String reason) {
        XwOrderRefundRecord orderRefundRecord = new XwOrderRefundRecord();
        orderRefundRecord.setCreateTime(LocalDateTime.now());
        orderRefundRecord.setOrderRefundId(refundId);
        orderRefundRecord.setMessage(message);
        orderRefundRecord.setReason(reason);
        save(orderRefundRecord);
    }

    @Override
    public List<XwOrderRefundRecord> findByRefundId(Integer refundId) {
        return list(new QueryWrapper<XwOrderRefundRecord>().eq("order_refund_id", refundId));
    }
}
